/**
 * Created with IntelliJ IDEA.
 * User: happyiu
 * Date: 2022-01-21
 * Time: 22:08
 * Description:
 */
/*
public class TestDemo {
    public static void main1(String[] args) {
        StringBuffer sb = new StringBuffer("helloworld");


    }

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder("helloworld");
    }
}
*/

public class TestDemo {

    /**
     * StringBuffer或者StringBuilder-》String
     * 调用toString方法
     *
     * @return
     */
    public static String func2() {
        StringBuilder sb = new StringBuilder();
        return sb.toString();
    }

    /**
     * String->StringBuffer或者StringBuilder
     * 使用构造方法
     *
     * @return
     */
    public static StringBuffer func() {
        String str = "abcdef";
        StringBuffer sb = new StringBuffer();
        sb.append(str);
        return sb;
        //return new StringBuffer(str);
    }

    public static void main(String[] args) {

    }
}
